using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ball : MonoBehaviour
{
    private Rigidbody2D ballRg;

    [SerializeField] float BallSpdMultiplier;
    
    private Vector2 targetVelDir;
    // Start is called before the first frame update
    void Start()
    {
        ballRg = this.GetComponent<Rigidbody2D>();

        targetVelDir = new Vector2(1f, 1f);
        targetVelDir = targetVelDir * BallSpdMultiplier;
        ballRg.AddForce(targetVelDir,ForceMode2D.Impulse);
    }

    // Update is called once per frame
    void Update()
    {

    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Edge" 
           // || true
           )
        {
            //Ball bounces off the edge
            //targetVelDir = Vector2.Reflect(targetVelDir, collision.GetContact(0).normal);
            //ballRg.velocity = targetVelDir;
        }
        
    }
}
